package com.edou.system.listener;

import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.ProgressListener;

import com.edou.base.constant.SessionConstant;
import com.edou.system.dto.SysUploadFileProcessVO;

/**
 * 文件上传进度监听器
 * @creator     admin
 * @create-time 2016年10月18日   下午2:42:18
 * @email admin@edou.com
 * @company www.edou.com
 * @version 1.0
 */
public class FileUploadProgressListener implements ProgressListener{
	
	private HttpSession session;
	
	public FileUploadProgressListener(HttpSession session) {
		super();
		this.session = session;
		SysUploadFileProcessVO status = new SysUploadFileProcessVO();
		session.setAttribute(SessionConstant.UPLOAD_FILE_PROCESS, status);
		
	}

	public void update(long pBytesRead, long pContentLength, int pItems) {
		SysUploadFileProcessVO status = (SysUploadFileProcessVO) session.getAttribute(SessionConstant.UPLOAD_FILE_PROCESS);
		status.setBytesRead(pBytesRead);
		status.setContentLength(pContentLength);
		status.setItems(pItems);
		session.setAttribute(SessionConstant.UPLOAD_FILE_PROCESS, status);
	}
}
